//########################################################################
//## (C) by Edwin Vriethoff under Microsoft Reciprocal License (Ms-RL)  ##
//## See http://www.codeplex.com/SPUserPoll/license for full license    ##
//##                                                                    ##
//## http://edwin.vriethoff.net http://www.codeplex.com/SPUserPoll/     ##
//########################################################################

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;

namespace SPUserPoll.Business.Components
{
    public class FeatureReceiver : SPFeatureReceiver
    {
        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            //The feature is activated
        }

        public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
        {
            try
            {
                SPSite site = properties.Feature.Parent as SPSite;
                using (SPWeb web = site.OpenWeb())
                {
                    //We will remove the SPUserPoll webpart file
                    SPFile wpFile = web.GetFile(@"/_catalogs/wp/PollDisplayWebPart.webpart");
                    wpFile.Delete();
                }
                site.Dispose();
                site.Close();
            }
            catch
            {
                //Deactivation failed
            }
        }

        public override void FeatureInstalled(SPFeatureReceiverProperties properties)
        {
            //The feautre is installed
        }

        public override void FeatureUninstalling(SPFeatureReceiverProperties properties)
        {
            //The feature is uninstalled
        }
    }
}
